package projet_final;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import diaporama.DiapoThread;
import create_album.Album;
import create_img.OpenImg;
@SuppressWarnings("serial")
public class MainWindow extends JFrame implements ActionListener{
	
	private JFrame frame;
	private JButton buttonDiapo, buttonOpen, buttonSearch, buttonTag, buttonAlbum, buttonQuit, buttonBonus;
	private JPanel panel;
	
	public JFrame getFrame()
	{
		return frame;
	}
	
	public MainWindow()
	{
			frame = new JFrame("The best Jphoto");
			frame.setSize(300, 400);
			frame.setLocation(200, 200);
			buttonDiapo = new JButton("Diaporama");
			buttonOpen = new JButton("Ouvrir Photo");
			buttonQuit = new JButton ("Quitter");
			buttonSearch = new JButton("Recherche par tag");
			buttonTag = new JButton("Add tag");
			buttonAlbum = new JButton("Creer un album");
			buttonBonus = new JButton("Bonus");
			panel = new JPanel();
			panel.setLayout(new GridLayout(2,4));
			panel.add(buttonOpen);
			panel.add(buttonDiapo);
			panel.add(buttonAlbum);
			panel.add(buttonSearch);
			panel.add(buttonTag);
			panel.add(buttonBonus);
			panel.add(buttonQuit);
			frame.getContentPane().add(panel, BorderLayout.CENTER);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			frame.pack();
			frame.setVisible(true);
			//ajout du action Listener pour le bouton Open
			buttonOpen.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					 new OpenImg();
				}
			});
			//ajout du action Listener pour le bouton Diapo
			buttonDiapo.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					// utilisation d un thread
					DiapoThread dt = new DiapoThread();
					dt.start();
				}
			});
			buttonQuit.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					System.exit(0);
				}
			});
			
			buttonAlbum.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					 new Album();
//					JOptionPane.showMessageDialog(null,"Sorry, not yet implemented", "Album creation",
//							JOptionPane.WARNING_MESSAGE);
				}
			});
			
			buttonSearch.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					// new Search();
					JOptionPane.showMessageDialog(null,"Sorry, not yet implemented", "Search factory",
							JOptionPane.WARNING_MESSAGE);
				}
			});
			
			buttonTag.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					// new Tag();
					JOptionPane.showMessageDialog(null,"Sorry, not yet implemented", "Tag factory",
							JOptionPane.WARNING_MESSAGE);
				}
			});
			
			buttonBonus.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					// new Bonus();
					JOptionPane.showMessageDialog(null,"Sorry, not yet implemented", "Bonus Factory",
							JOptionPane.WARNING_MESSAGE);
				}
			});
		}
	
	
		public static void main(String[] args) {
			// Set the look and feel to Java Swing Look
			new MainWindow();
//			new Diaporama();
		}


		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			
		}
}